package com.uchedao.seller.ui.car.publish;

import android.content.Intent;
import android.view.View;
import android.widget.CheckBox;

import com.uchedao.seller.R;
import com.uchedao.seller.ui.car.base.BasePublishActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * 车况描述
 */
public class VehicleSelectActivity extends BasePublishActivity {

    private List<CheckBox> cbs;

    @Override
    protected String getActivityTag() {
        return "VehicleSelectActivity";
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_vehicle_select;
    }

    @Override
    protected void initView() {
        initToBar("车况描述");
        btnTopRight1.setVisibility(View.VISIBLE);
        btnTopRight1.setText("保存");

        cbs = new ArrayList<CheckBox>();
        cbs.add((CheckBox) findViewById(R.id.cbVehilceSelect1));
        cbs.add((CheckBox) findViewById(R.id.cbVehilceSelect2));
        cbs.add((CheckBox) findViewById(R.id.cbVehilceSelect3));
        cbs.add((CheckBox) findViewById(R.id.cbVehilceSelect4));
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {
        btnTopRight1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StringBuilder sb = new StringBuilder();
                for(CheckBox cb : cbs)
                    if(cb.isChecked())
                        sb.append(cb.getText()).append(" ");
                Intent data = new Intent();
                data.putExtra("data", sb.toString());
                setResult(RESULT_OK, data);
                finish();
            }
        });
    }
}
